<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/page_init.jsp"%>
<%@ page import="java.util.Map"%>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>Insert title here</title>
	<script type="text/javascript" src="<%=contextPath%>/js/console/md5.js"></script>
</head>
<%
	JSONObject user = (JSONObject) request.getAttribute("user");
	String editable = "0";
	if(user!=null){
		JSONObject userAttr = JSONObject.parseObject(user.getString("attr")==null?"{}":user.getString("attr"));
		if(userAttr.getString("editable")!=null){
			editable = userAttr.getString("editable");
		}
	}
%>
<body>
 
   <div class="main-right l">
    <div class="main-right-scroll">
      <div class="title-bt"><span class="pl10">修改运维用户信息</span><span class="pr10 tr">
        <button class="btn-28" onclick="back();">返回</button>
        </span></div>
      <div class="right-content">
          <div class="operate-nav">
            <div class="operate-title"><span>密码信息</span></div>
            <div class="operate-contant">
              <table width="100%" border="0" cellspacing="0" cellpadding="0" >
                <tr>
                  <td width="10%" class="mandatory">登录ID:</td>
                  <td width="40%">
                  <%=user.getString("loginId") %>
                   </td>
                </tr>
                <tr>
                  <td width="10%" class="mandatory">用户名:</td>
                  <td width="40%">
                  <input type="text" id="name" name="name" class="width-180" value='<%=user.getString("name") %>'/>
                   </td>
                </tr>
                <tr>
                  <td width="10%" class="mandatory">读写属性:</td>
                  <td width="40%">
                  	  <select id="editable" class="width-180">
                  	  	<option value="0" <%if(editable.equals("0")) {%>selected="selected" <%} %>>只读</option>
                  	  	<option value="1" <%if(editable.equals("1")) {%>selected="selected" <%} %>>读写</option>
                  	  </select>
                  </td>
                </tr>
              </table>
            </div>
          </div>
          	<input type="hidden" id="id" name="id" value='<%=user.getString("id") %>' />
			<input type="hidden" id="usertype" name="usertype" value='<%=user.getString("usertype") %>' />
			<input type="hidden" id="loginId" name="loginId" value='<%=user.getString("loginId") %>' />
			<input type="hidden" id="menuIds" name="menuIds" value='<%=user.getString("menuIds") %>' />
			<input type="hidden" id="password" name="password" value='<%=user.getString("password") %>' />
        <div class="mt10 mb10 tr"><button class="btn-28" id="update_tpl_btn">保存</button></div>
      </div>
    </div>
  </div>
	<script type="text/javascript">
		$(function() {
			$("#update_tpl_btn").on("click", function() {
				
				var name = $("#name").val();
				var editable = $("#editable").val();
				
				if(name==''){
					apexLayer.Warn("请输入用户名！");
					return;
				}
				Ajax({
					url: contextPath+"/console/user/uptSystemUserInfo",
					isMask : true,
					data: {
						"id": $("#id").val(),
						"loginId": $("#loginId").val(),
						"name": $("#name").val(),
						"menuIds": $("#menuIds").val(),
						"usertype": $("#usertype").val(),
						"editable": editable,
						"password": $("#password").val(),
					},
					success: function (data) {
						if (data.success) {
							apexLayer.Msg("修改成功！",1000,function(){
								self.parent.window.location = contextPath+"/console/user/list";
							});
						} else {
							apexLayer.Warn(data.note);
						}
					}
				});
			});
		});
		
		function back(){
			self.window.location=contextPath+'/console/user/list';
		}
		
	</script>
</body>
</html>